package com.bwton.msx.ccb.widget.dialog;


import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.DialogFragment;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.bwton.msx.ccb.R;

public class ProgressDialogFragment extends DialogFragment {

    public final static String BUNDLE_MESSAGE = "BUNDLE_MESSAGE";

        public static ProgressDialogFragment newInstance() {
        return newInstance(null);
    }

    public static ProgressDialogFragment newInstance(String message) {
        ProgressDialogFragment fragment = new ProgressDialogFragment();
        if (!TextUtils.isEmpty(message)) {
            Bundle args = new Bundle();
            args.putString(BUNDLE_MESSAGE, message);
            fragment.setArguments(args);
        }
        return fragment;
    }

    //@BindView(R.id.message)
    TextView mTxtMessage;

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setStyle(STYLE_NORMAL, R.style.Dialog_Progress);
    }

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
                             @Nullable Bundle savedInstanceState) {
        View view =  inflater.inflate(R.layout.dialog_progress, container);
//        ButterKnife.bind(this,view);
        mTxtMessage = view.findViewById(R.id.message);
        return view;
    }

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        if (getArguments()!=null) {
            mTxtMessage.setText(getArguments().getString(BUNDLE_MESSAGE));
        }
    }
}
